package com.bird.pro.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import com.bird.pro.interceptor.AuthInterceptor;
import com.bird.pro.interceptor.SystemInterceptor;

@Configuration
public class WebAppConfig extends WebMvcConfigurationSupport {

	/**
	 * 过滤器
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// 移动端过滤，需要微信登录
		registry.addInterceptor(authInterceptor()).addPathPatterns("/wechat/**");
		// 后台拦截
		registry.addInterceptor(systemInterceptor()).addPathPatterns("/**");
	}

	/**
	 * 静态资源
	 */
	@Override
	protected void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
	}
	

	@Bean
	public SystemInterceptor systemInterceptor() {
		return new SystemInterceptor();
	}
	
	@Bean
	public AuthInterceptor authInterceptor() {
		return new AuthInterceptor();
	}
}
